package com.cg.config;

import com.cg.common.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {

    @Bean
    public Queue queue(){//队列
        return new Queue(Constants.MQ.MAIL_QUEUE,true);
    }

    @Bean
    public TopicExchange topicExchange(){//交换机
        return new TopicExchange(Constants.MQ.MAIL_EXCHANGE);
    }

    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with(Constants.MQ.MAIL_KEY);
    }

}
